package cn.cslg.news.captcha;

import java.util.Random;

import javax.servlet.annotation.WebServlet;


@WebServlet(urlPatterns="/ncc")
public class NumberCharCaptcha extends AbstractCaptchaServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7281998306308050532L;

	@Override
	public String[] generateCaptcha() {
		String cipher = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		StringBuilder s = new StringBuilder();
		Random rand = new Random(System.currentTimeMillis());
		for (int i = 0; i < 4; i++) {
			s.append(cipher.charAt(rand.nextInt(cipher.length())));
		}
		String code = s.toString();
		return new String[] { code, code };
	}

}
